<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/mytaglib.tld" prefix="mytag" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:setBundle basename="ua.races.raceBundle"/>
<html>
<head>
    <title>Administrator's workplace</title>
</head>
<body>
<c:set var="logoutText"><fmt:message key="logout"/></c:set>
<mytag:logout text="${logoutText}"/>

<c:set var="dateText"><fmt:message key="races.date"/></c:set>
<c:set var="submitAddText"><fmt:message key="admin.submit.add"/></c:set>
<c:set var="submitSetResultsText"><fmt:message key="admin.submit.set.results"/></c:set>
<c:set var="timeText"><fmt:message key="races.startTime"/></c:set>
<c:set var="actionText"><fmt:message key="races.action"/></c:set>
<c:set var="stadiumText"><fmt:message key="races.stadium"/></c:set>
<c:set var="addNewHorseText"><fmt:message key="admin.add.new.horse"/></c:set>
<c:set var="horseNameText"><fmt:message key="admin.horse.name"/></c:set>
<c:set var="addNewRaceText"><fmt:message key="admin.add.new.race"/></c:set>
<c:set var="numberText"><fmt:message key="admin.select.number"/></c:set>


<form action="addHorse.do" method="GET">
    <table align="center" border="2">
        <tr>
            <td>${addNewHorseText}</td>
            <td>${horseNameText}</td>
            <td><input type="text" name="horseName"/></td>
            <td><input type="submit" value="${submitAddText}"/></td>
        </tr>
    </table>
</form>

<form action="prepareAddRace.do" method="GET">
    <table align="center" border="2">
        <tr>
            <td>${addNewRaceText}</td>
            <td>${numberText}</td>
            <td><input type="text" name="numberOfHorses"/></td>
            <td><input type="submit" value="${submitAddText}"/></td>
        </tr>
    </table>
</form>

<h3 align="center">Finished races without results : </h3>
<jsp:useBean id="races" type="java.util.List" scope="request"/>
<table align="center" summary="" border="1" bgcolor="#fff0f5">
    <thead bgcolor="#faebd7">
    <tr>
        <th>${dateText}</th>
        <th>${timeText}</th>
        <th>${stadiumText}</th>
        <th>${actionText}</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="race" items="${races}">
        <form action="prepareResults.do" method="GET">
            <tr>
                <td><input type="hidden" name="raceId" value="${race.raceId}"><c:out value="${race.raceDate}"/></td>
                <td><c:out value="${race.startTime}"/></td>
                <td><c:out value="${race.stadium}"/></td>
                <td><input type="submit" value="${submitSetResultsText}"/></td>
            </tr>
        </form>
    </c:forEach>
    </tbody>
</table>


</body>
</html>